#pragma once
//#include <pthread.h>

class Mutex
{
    pthread_mutex_t *_pmtx;

public:
    Mutex(pthread_mutex_t *pmtx)
        : _pmtx(pmtx)
    {
    }
    void lock()
    {
        pthread_mutex_lock(_pmtx);
    }
    void unlock()
    {
        pthread_mutex_unlock(_pmtx);
    }
};

class LockGuard
{
    Mutex _mutex;

public:
    LockGuard(pthread_mutex_t *pmtx)
        : _mutex(pmtx)
    {
        _mutex.lock();
    }
    ~LockGuard()
    {
        _mutex.unlock();
    }
};